package Work4.Slay_the_Maze.GameSystem;

import Work4.Slay_the_Maze.Player.*;
import Work4.Slay_the_Maze.Cards.*;
import java.util.Random;
import java.util.ArrayList;
import java.util.Scanner;

public class BattleReward extends Reward {
	
	@Override
	public void Reward(Player player) {
		Random rd=new Random();
		int coin=rd.nextInt(100)+30;
		System.out.println("获得金币:"+coin);
		player.addmoney(coin);
		System.out.println("获得卡牌:");
		CardsPool cardspool=new CardsPool();
		ArrayList<Cards> card =new ArrayList<Cards>();
		int t=0;
		while(t<3) {
			Cards tempcard=cardspool.RandomgetCard();
			if(!card.contains(tempcard)) {
				card.add(tempcard);
				t++;
			}
		}
		for(int i=0;i<card.size();i++) {
			System.out.printf("["+(i+1)+"] ");
			card.get(i).PrintInfo();
		}
		System.out.printf("选择:");
		Scanner sc=new Scanner(System.in);
		int choice;
		do {
			System.out.println("输入1，2，3进行选择(输入0退出)");
			while (!sc.hasNextInt()) {
			    System.out.println("输入无效，请输入一个整数:");
			    sc.next(); // 清除错误输入，避免死循环
			}
			choice=sc.nextInt();
		}while(choice!=1&&choice!=2&&choice!=3&&choice!=0);
		if(choice==0) {
			return;
		}
		player.addhandcard(card.get(choice-1));
	}
	
	public void MoreReward(Player player) {
		System.out.println("获得卡牌:");
		CardsPool cardspool=new CardsPool();
		ArrayList<Cards> card =new ArrayList<Cards>();
		Random rd=new Random();
		int t=0;
		while(t<3) {
			Cards tempcard=cardspool.RandomgetCard();
			if(!card.contains(tempcard)) {
				card.add(tempcard);
				t++;
			}
		}
		for(int i=0;i<card.size();i++) {
			System.out.printf("["+(i+1)+"] ");
			card.get(i).PrintInfo();
		}
		System.out.printf("选择:");
		Scanner sc=new Scanner(System.in);
		int choice;
		do {
			System.out.println("输入1，2，3进行选择(输入0退出)");
			while (!sc.hasNextInt()) {
			    System.out.println("输入无效，请输入一个整数:");
			    sc.next(); // 清除错误输入，避免死循环
			}
			choice=sc.nextInt();
		}while(choice!=1&&choice!=2&&choice!=3&&choice!=0);
		if(choice==0) {
			return;
		}
		player.addhandcard(card.get(choice-1));
	}
}
